package pr.iceworld.fernando.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import lombok.Data;

import javax.persistence.Transient;
import java.util.List;


@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel("用户信息")
public class User<Long> extends DefaultDateEntity implements IdEntity {
    public final static int STATUS_UNAUTH = 0;
    public final static int STATUS_OK = 1;
    public final static int STATUS_LOCKED = 2;
    private Long id;
    private String username;
    /**
     * 名称（昵称或者真实姓名，不同系统不同定义）
     */
    private String name;
    private String password;
    /**
     * 加密密码的盐
     */
    private String salt = "USER_C";
    private String email;
    /**
     * 用户状态,0:创建未认证（比如没有激活，没有输入验证码等等）--等待验证的用户 , 1:正常状态,2：用户被锁定.
     */
    private Integer status;
    /**
     * 立即从数据库中进行加载数据
     */
    @Transient
    private List<Role> roles;

    @Transient
    private List<Permission> permissions;

    public String getCredentialsSalt() {
        return username + salt;
    }
}
